package com.example.bitintershipbbs.mapper;

import com.example.bitintershipbbs.model.Post;
import javafx.geometry.Pos;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.lang.reflect.Array;
import java.util.List;

@Mapper
public interface PostMapper {
    @Insert("insert into dbpost(title,description,type,location,position,sallary,gmt_create,gmt_modified,creatorid) values (#{title},#{description},#{type},#{location},#{position},#{sallary},#{gmt_create},#{gmt_modified},#{creatorid})")
    void createPost(Post post);

    @Select("select * from dbpost where id = #{post_id}")
    Post getPostById(@Param("post_id") Integer post_id);

    @Select("select * from dbpost order by gmt_modified desc limit 10")
    List<Post> getLatest10();

    @Select("select * from dbpost where creatorid = #{user_id}")
    List<Post> getListById(@Param("user_id") Integer id);
}
